import json

from celery import shared_task

from tools.baiduapi import bdapi
from tools.myredis import r


@shared_task
def bdcardmes():
    #从redis list中获取三条信息
    #调用百度api接口
    #将结果存入redis
    blist=r.list_lrange('idcardlist',0,3)
    print(blist,1111111111)
    if blist:
        for i in blist:
            picurl = i.decode('utf-8')
            mes = bdapi.idcard(picurl)
            # 存入redis
            r.set_str(picurl, json.dumps(mes))
            r.list_del('idcardlist', picurl)

    print('调用百度api接口')


